package com.tq.teaching_quality.controller;


import com.tq.teaching_quality.entity.SurveyQuestionChoice;
import com.tq.teaching_quality.entity.SurveyQuestionChoice;
import com.tq.teaching_quality.mapper.SurveyQuestionMapper;
import com.tq.teaching_quality.service.SurveyQuestionChoiceService;
import com.tq.teaching_quality.service.SurveyQuestionChoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 问卷题侯选项目 前端控制器
 * </p>
 *
 * @author YTH
 * @since 2020-06-29
 */
@RestController
@RequestMapping("/survey-question-choice")
public class SurveyQuestionChoiceController {

    @Autowired
    private SurveyQuestionChoiceService surveyQuestionChoiceService;
    @Autowired
    private SurveyQuestionMapper surveyQuestionMapper;

    //添加一条记录
    public boolean AddSurveyQuestionChoice(@PathVariable("SurveyQuestionChoice") List<SurveyQuestionChoice> surveyQuestionChoices) {
        for (int i = 0; i < surveyQuestionChoices.size(); i++) {
            surveyQuestionChoices.get(i).setSurveyQuestionId(surveyQuestionMapper.SelectMaxId());
            surveyQuestionChoiceService.save(surveyQuestionChoices.get(i));
        }
        return true;
    }

    //删除一条记录
    @RequestMapping("/DeleteSurveyQuestionChoice")
    public boolean DeleteSurveyQuestionChoice(@PathVariable("SurveyQuestionChoiceId") Long SurveyQuestionChoiceId) {
        return surveyQuestionChoiceService.removeById(SurveyQuestionChoiceId);
    }

    //查询全部记录
    @RequestMapping("/SelectAllSurveyQuestionChoice")
    public List<SurveyQuestionChoice> SelectAllSurveyQuestionChoice() {
        return surveyQuestionChoiceService.list();
    }

    //修改一条记录
    @RequestMapping("/UpdateSurveyQuestionChoice")
    public boolean UpdateSurveyQuestionChoice(@PathVariable("SurveyQuestionChoice") SurveyQuestionChoice SurveyQuestionChoice) {
        return surveyQuestionChoiceService.updateById(SurveyQuestionChoice);
    }


}

